package com.yc.mvc;

import com.yc.mvc.web.TimeConvertor;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
@EnableWebMvc // 开启mvc配置
public class MvcConfig implements WebMvcConfigurer {

    @Resource
    TimeConvertor tc;
    // 用于添加转换器和格式化对象
    @Override
    public void addFormatters(FormatterRegistry registry) {
        System.out.println("=======================");
        // 注册自定义的转换器
        registry.addConverter(tc);
    }
}
